<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>人员管理</title>
    <meta name="keywords" content="">
    <meta name="description" content="">

    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="__STATIC__/layout/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="__STATIC__/layout/css/font-awesome.css?v=4.4.0" rel="stylesheet">
    	<link href="__STATIC__/layout/css/gyq.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/layout/css/demo.css" type="text/css">
    <link href="__STATIC__/layout/css/animate.css" rel="stylesheet">
    <link href="__STATIC__/layout/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="__STATIC__/layout/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
    <link rel="stylesheet" href="__STATIC__/zTreeStyle/demo.css" type="text/css">
    <link rel="stylesheet" href="__STATIC__/zTreeStyle/zTreeStyle.css" type="text/css">
   
     <link rel="stylesheet" href="__STATIC__/layout/css/channel.css" type="text/css">
    <style>
       .alerts{display:none;position:fixed;top:0;left:0;width: 100%;height: 100%;background: rgba(0,0,0,0.5);}
       .alerts .alerts_content{background:#fff;position: fixed;top: 50%;left: 50%; width: 700px;min-height: 500px;margin: -220px 0 0 -350px;padding:5px;border:4px solid #ccc/* margin 负值为宽高的一半 */}
        .wait{ display:none;background:#f4f4f5;position: fixed;top: 50%;left: 50%; width: 700px;min-height: 250px;margin: -220px 0 0 -350px;padding:5px;border:4px solid #ccc/* margin 负值为宽高的一半 */}
       .alerts .alerts_content h3{font-weight: normal;text-align:left;line-height: 24px;font-size: 16px;padding-left: 1%;width: 99%;margin-bottom:30px;background: #d0e0e0}
       .alerts .alerts_content .alerts_form{
        width:100%;
       }
         .alert_addNewZone_tree{display:none;position:fixed;top:0;left:0;width: 100%;height: 100%;background: rgba(0,0,0,0.5);}
       .alert_addNewZone_tree .alert_addNewZone_content_tree{background:#fff;position: fixed;top: 50%;left: 50%; width: 500px;height: 300px;margin: -150px 0 0 -250px;border:4px solid #ccc;box-sizing: border-box;overflow: hidden;/* margin 负值为宽高的一半 */}
       .alert_addNewZone_tree .alert_addNewZone_content_tree h3{font-weight: normal;text-align:left;line-height: 24px;font-size: 16px;padding-left: 1%;width: 100%;background: #d0e0e0}
       .alert_addNewZone .alert_addNewZone_content .alert_addNewZone_form{
        width:100%;
       }
       .alert_addNewZone_tree .alert_addNewZone_content_tree .alert_addNewZone_form_tree{
        height: 280px;
        width: 100%;
        overflow-x: hidden;
    	overflow-y: auto;
       }
       .alerts .alerts_content .alerts_form form{width: 100%;}
       .alerts .alerts_content .alerts_form form div{margin-bottom:30px;width: 100%;text-align: center;}
       .alerts .alerts_content .alerts_form form div label{display:inline-block;width: 130px;text-align: right;}
       .alerts .alerts_content .alerts_form form div:nth-of-type(1) input{margin-right: 28px;}
        .mtp{margin-top:3px;}
        .no-padding{padding: 0;}
        #gopage{color:blue;cursor: pointer;}
        #firstpage{cursor: pointer;}


           .alert_addNewZone_tree{display:none;position:fixed;top:0;left:0;width: 100%;height: 100%;background: rgb(255,255,255,0.7);z-index: 200}
       .alert_addNewZone_tree .alert_addNewZone_content_tree{background:#fff;position: fixed;top: 50%;left: 50%; width: 500px;height: 350px;margin: -150px 0 0 -250px;border:4px solid #ccc;box-sizing:border-box;overflow: hidden;/* margin 负值为宽高的一半 */}
       .wait,.waits{background:#f4f4f5;position: fixed;top: 50%;left: 50%; width: 500px;height: 300px;margin: -150px 0 0 -250px;padding:5px;border:4px solid #ccc/* margin 负值为宽高的一半 */}
       .alert_addNewZone_tree .alert_addNewZone_content_tree h3{font-weight: normal;text-align:left;line-height: 24px;font-size: 16px;padding-left: 1%;width: 100%;background: #d0e0e0}
    </style>
</head>

<body class="white-bg" style="color:#333;padding:3px;font-size:12px;overflow-y:auto;">
 
           <div class="page-heade">
       <h2 class="title_color text-center">	{if condition="$emid eq 0"}
			新增人员
			{else/}
			人员编辑
			{/if}</h2>
    </div>
        <input type="hidden" value="{$emid}" id="employee_id"/>
        <div class="col-md-12 no-padding">
			
				<table class="table table-bordered" style="width: 100%;">
					<tr class='font-bold info'>
						<td colspan="4">基础信息设置</td>
					</tr>
					<tr>
						<td style="width: 15%;">档案编号<span style="color: red">*</span>:</td>
						<td style="width:35%;"><input type="text" id="em_num" class="form-control" {if condition="$emid neq 0"}readonly value='{$data.em_no}' {/if}/></td>
						<td style="width: 15%;">目前状态:</td>
						<td style="width:35%;">
							<label><input type="radio" name="state" value='1' {if condition="$data.state eq 1"}checked{/if}/>在职</label>
							<label><input type="radio" name="state" value='2' {if condition="$data.state eq 2"}checked{/if}/>试用</label>
							<label><input type="radio" name="state" value='3'  {if condition="$data.state eq 3"}checked{/if}/>离职</label>
						</td>
					</tr>
					<tr>
						<td style="width: 15%;">姓名<span style="color: red">*</span>:</td>
						<td style="width:35%;"><input type="text" value="{$data.em_name}" id="em_name" class="form-control"/></td>
						<td style="width: 15%;">手机号<span style="color: red">*</span>:</td>
						<td style="width:35%;">
							<input type="text" id="mobile" value="{$data.mobile}" class="form-control"/>
						</td>
					</tr>
					<tr>
						<td style="width: 15%;">微信号:</td>
						<td style="width:35%;"><input type="text" id="wechart" value="{$data.WeChat}" class="form-control"/></td>
						<td style="width: 15%;">邮箱:</td>
						<td style="width:35%;">
							<input type="text" id="email" class="form-control" value="{$data.email}"/>
						</td>
					</tr>
					<tr>
						<td style="width: 15%;">身份证号码:</td>
						<td style="width:35%;"><input type="text" value="{$data.idcard}" id="idcard" class="form-control"/></td>
						<td style="width: 15%;">入职日期:</td>
						<td style="width:35%;">
							 <input readonly class="form-control layer-date" id="entry" value="{$data.entry}">
                                            <label class="laydate-icon inline demoicon" onclick="laydate({elem: '#entry'});"></label>
						</td>
					</tr>
					<tr>
						<td style="width: 15%;">性别:</td>
						<td colspan="3">
							<label><input type="radio" name="gender" value='1' {if condition="$data.gender eq 1"}checked{/if}/>男</label>
							<label><input type="radio" name="gender" value='0' {if condition="$data.gender eq 0"}checked{/if}/>女</label>
							
						</td>
						
					</tr>
					<tr class='font-bold info'>
						<td colspan="4" >部门信息设置</td>
					</tr>
					<tr>
						<td style="width: 15%;">主部门<span style="color: red">*</span>:</td>
						<td style="width:35%;">
							<span id="depart_kg">
								{if condition="$data.de_id neq ''"}
									<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'><span class='departsdename'>{$data.de_name}</span>&nbsp;&nbsp;<span onclick='qxde();' style='cursor:pointer;font-size: 16px;'>x</span></span>
								{/if}
							</span>
							<input type="hidden" value='{$data.de_id}'  id="de_id"/>
							<a href="javascript:;" id="choose_depart">选择部门</a>
						</td>
						<td style="width: 15%;">设为第一负责人:</td>
						<td style="width:35%;">
							<select id="is_main" class="form-control" style="padding: 2px 12px;width: 60px">
								<option value='0'>否</option>
								<option value='1' {if condition="$emid eq $data.principal"}selected{/if}>是</option>
							</select>
							<span style="color: red">(如选择是将替换原先第一负责人)</span>
						</td>
					</tr>
					<tr>
						<td style="width: 15%;">岗位:<span style="color: red">*</span></td>
						<td colspan="3">
							<span id="job_kg">
								{if condition="$data.job_id neq ''"}
									<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>{$data.job_name}&nbsp;&nbsp;<span onclick='qxjob();' style='cursor:pointer;font-size: 16px;'>x</span></span>
								{/if}
							</span>
							<input type="hidden" value='{$data.job_id}'  id="job_id"/>
							<a href="javascript:;" id="choose_job_this">选择本部门岗位</a>
							<a href="javascript:;" id="choose_job_all">选择全部岗位</a>
							<a href="javascript:;" id="new_job">新增岗位</a>
						</td>
						
					</tr>
					<tr>
						<td style="width: 15%;">所属其他部门:</td>
						<td colspan="3">
							<span id="odepart_kg">
								{volist name="dataodepart" id="vo"}
									<span did='{$vo.id}' style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>{$vo.de_name}&nbsp;&nbsp;<span onclick='qxode({$vo.id});' style='cursor:pointer;font-size: 16px;'>x</span></span>
								{/volist}
							</span>
							<a href="javascript:;" id="choose_other_depart">选择</a>
							
						</td>
						
					</tr>
					<tr class='font-bold info'>
						<td colspan="4">用户信息设置</td>
					</tr>
					<tr>
						<td style="width: 15%;">用户名:</td>
						<td colspan="3">
							<input type="hidden" id="login_id" value="{$data.login_id}"/>
							<input type="text" id="login_name" {if condition="$data.login_name neq ''"}value="{$data.login_name}" readonly {/if} class="form-control" style="width:50%;"/>
							<span style="color: red">(注意：1.格式4~16位字母、数字、下划线组成 2.用户名不可重复 3.如填写必须完善角色信息 4如不填写将不创建登录帐号)</span>
						</td>
					</tr>
					<tr>	
						<td style="width: 15%;">密码:</td>
						<td colspan="3">
							<input type="text" id="login_pwd" {if condition="$data.login_name neq ''"}value="******" readonly {/if} class="form-control" style="width:50%;"/>
							(4~8位字母数字组成){if condition="$data.login_name neq ''"}<button class='btn btn-sm btn-primary' onclick="zcpwd({$data.login_id});">重置密码</button> {/if}
						</td>
					</tr>
					<tr>
						<td style="width: 15%;">用户类型:</td>
						<td style="width:35%;">

							<label><input type="radio" name="user_type" value='1' {if condition="$data.utype neq 2"}checked{/if}/>一般用户</label>
							<label><input type="radio" name="user_type" value='2' {if condition="$data.utype eq 2"}checked{/if}/>超级用户</label>
							
						</td>
						<td style="width: 15%;">状态:</td>
						<td style="width:35%;">
							<label><input type="radio" name="user_state" value='1' {if condition="$data.ustate neq 0"}checked{/if}/>正常</label>
							<label><input type="radio" name="user_state" value='0' {if condition="$data.ustate eq 0"}checked{/if}/>冻结</label>
						</td>
					</tr>
					<tr>
						<td style="width: 15%;">是否SFA用户:</td>
						<td style="width:35%;">
							<label><input type="radio" name="user_is_SFA" value='0' {if condition="$data.is_SFA neq 1"}checked{/if}/>不是</label>
							<label><input type="radio" name="user_is_SFA" value='1' {if condition="$data.is_SFA eq 1"}checked{/if}/>是</label>
							
						</td>
						<td style="width: 15%;">允许移动端登录:</td>
						<td style="width:35%;">
							<label><input type="radio" name="user_power" value='1' {if condition="$data.power neq 0"}checked{/if}/>是</label>
							<label><input type="radio" name="user_power" value='0' {if condition="$data.power eq 0"}checked{/if}/>否</label>
						</td>
					</tr>
					<tr class='font-bold info'>
						<td colspan="4">角色信息设置</td>
					</tr>
					<tr>
						<td style="width: 15%;">角色:</td>
						<td style="width:35%;">
							<span id="role_kg">
								{if condition="$data.rid neq ''"}
									<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>{$data.role_name}&nbsp;&nbsp;<span onclick='qxrole();' style='cursor:pointer;font-size: 16px'>x</span></span>
								{/if}
							</span>
							<input type="hidden" id="role_id" value='{$data.rid}'/>
							<a href="javascript:;" id="choose_role">选择角色</a>
							<a href="javascript:;" id="new_role">新增角色</a>
							<a href="javascript:;" id="update_role">修改角色</a>
							
						</td>
						<td style="width: 15%;">上级角色:</td>
						<td style="width:35%;">
							<span id="prole_kg">

							</span>
							<input type="hidden" id="prole_id" value=''/>
							
						</td>
					</tr>
					<tr>
						<td style="width: 15%;">本角色包含职员(最多显示10位):</td>
						<td style="color:red;" id="role_other_people" >
							
						</td>
						<td>上级角色包含职员</td>
						<td style="color:red;" id="p_role_people"></td>
						
					</tr>
					<tr>
						<td style="width: 15%;">权限设定:</td>
						<td colspan="3">
							<a href="javascript:;" id="update_power">设置web端权限</a>
						</td>
						
					</tr>
					<tr>
						<td style="width: 15%;">角色组:</td>
						<td colspan="3">
							<span id="roleg_kg">
								{if condition="$data.rgid neq ''"}
								<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'><span class='departsdename'>{$data.group_name}</span>&nbsp;&nbsp;<span onclick='qxroleg();' style='cursor:pointer;font-size: 16px'>x</span></span>
								{/if}
							</span>
							<input type="hidden" id="roleg_id" value='{$data.rgid}'/>
							<a href="javascript:;" id="choose_roleg">选择已存在角色组</a>
							<a href="javascript:;" id="new_roleg">新增角色组</a>
							<a href="javascript:;" id="up_roleg">编辑角色组</a>
						</td>
						
					</tr>
					<tr>
						<td style="width: 15%;">角色组包含角色:</td>
						<td colspan="3" id="cont_role">
							
						</td>
						
					</tr>
					<tr class='font-bold info'>
						<td colspan="4">客户信息设置</td>
					</tr>
					<tr>
						<td style="width: 15%;">经销商列表:</td>
						<td style="width:35%;">
							<div class="col-xs-4">
		                        <div class="input-group" id="jxs_input" >
		                            <input type="text"   placeholder="请输入关键字或空格查询" class="form-control jxslist" id="jxslist" name="jxslist" value="">
		                            <div class="input-group-btn">
		                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
		                                    <span class="caret"></span>
		                                </button>
		                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
		                                </ul>
		                            </div>
		                        </div>
		                       
		                    </div>
		                    <div class="col-xs-2">
		                        <a id="select_jxs">选择</a>
		                    </div>
						</td>
						<td colspan="2">
							<div class="duoxuan" id="selected_jxs">
							{volist name="jxss" id="r"}
							<span class="ren prolist" data-id="{$r.id}">{$r.title}<span class="close">×</span></span>
							{/volist}
							</div>
						</td>
					</tr>
					<tr>
						<td style="width: 15%;">系统列表:</td>
						<td style="width:35%;">
							<div class="col-xs-4">
		                        <div class="input-group" id="sys_input" >
		                            <input type="text"   placeholder="请输入关键字或空格查询" class="form-control syslist" id="syslist" name="syslist" value="">
		                            <div class="input-group-btn">
		                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
		                                    <span class="caret"></span>
		                                </button>
		                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
		                                </ul>
		                            </div>
		                        </div>
		                       
		                    </div>
		                    <div class="col-xs-2">
		                        <a id="select_sys">选择</a>
		                    </div>
						</td>
						<td colspan="2">
							<div class="duoxuan" id="selected_sys">
							{volist name="syss" id="r"}
							<span class="ren prolist" data-id="{$r.id}">{$r.title}<span class="close">×</span></span>
							{/volist}
							</div>
						</td>
					</tr>
					<tr>
						<td style="width: 15%;">网点列表:</td>
						<td style="width:35%;">
							<div class="col-xs-4">
		                        <div class="input-group" id="net_input" >
		                            <input type="text"   placeholder="请输入关键字或空格查询" class="form-control netlist" id="netlist" name="netlist" value="">
		                            <div class="input-group-btn">
		                                <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown">
		                                    <span class="caret"></span>
		                                </button>
		                                <ul class="dropdown-menu dropdown-menu-right" role="menu">
		                                </ul>
		                            </div>
		                        </div>
		                       
		                    </div>
		                    <div class="col-xs-2">
		                        <a id="select_net">选择</a>
		                    </div>
						</td>
						<td colspan="2">
							<div class="duoxuan" id="selected_net">
							{volist name="nets" id="r"}
							<span class="ren prolist" data-id="{$r.id}">{$r.title}<span class="close">×</span></span>
							{/volist}
							</div>
						</td>
					</tr>
					<tr class='font-bold text-center'>
						<td colspan="4">
							<button id="submits" class="btn btn-sm btn-primary">提交</button>
							<button id="back" class="btn btn-sm btn-warning">返回列表</button>
						</td>
						
					</tr>
				</table>
				<div style="height: 150px;"></div>

				
			</div>
		<!--树状弹框-->
		<div class="alert_addNewZone_tree">
	        <div class="alert_addNewZone_content_tree animated fadeInUp">
	            <h3><span id="txtree"></span><a style="float: right;margin-right: 10px;font-size: 16px" id="del_this1">&times;</a></h3>
	            <div  class="alert_addNewZone_form_tree" id="fenqu_fzr">
	              <ul id="tree_em" class="ztree"></ul>
	               <div class="quedingbtn" style="position: absolute;right: 0;bottom: 10px;"><button class="btn btn-sm btn-primary" id="qd">确定</button></div>
	            </div>
	            
	        </div>
	        <div class="wait">
   				<div class="ibox ">
                    <div class="ibox-title">
                        <h5>正在处理，请稍后.....</h5>
                    </div>
                    <div class="ibox-content">
                        <div class="spiner-example">
                            <div class="sk-spinner sk-spinner-chasing-dots">
                                <div class="sk-dot1"></div>
                                <div class="sk-dot2"></div>
                            </div>
                        </div>
                    </div>
                </div>

	        </div>
  		 </div>
        <!--树状弹框-->
    <!--新增岗位弹框-->
	<div class="alert_addjob alerts">
        <div class="alerts_content animated fadeInUp">
            <h3><span id="istj">新增岗位</span><a style="float: right;margin-right: 10px;font-size: 16px" id="del_this">&times;</a></h3>
            <div  class="alerts_form">
                <form id="newdepart">
                   	<table class="table table-bordered">
							
							<tr>
								<td class="text-right font-bold" >岗位名称<span style="color: red">*</span>:</td>
								<td><input type="text"  id="new_job_name" class="form-control" /></td>
								<td class="text-right font-bold" >对外称谓<span style="color: red">*</span>:</td>
								<td><input type="text"   id="new_job_title" class="form-control" /></td>
								
							</tr>
							<tr>
								<td class="text-right font-bold" >上级岗位:</td>
								<td>
									<input type="hidden" id="new_pid"/>
									<span id="new_pid_kg"></span>
									<a href="javascript:;" class="new_job_partent_id">选择</a>
								</td>
								<td class="text-right font-bold" >岗位编码<span style="color: red">*</span>:</td>
								<td><input type="text"  id="new_job_no" class="form-control" /></td>
								
							</tr>
							<tr>
								<td class="text-right font-bold" >岗位等级<span style="color: red">*</span>:</td>
								<td><input type="text"   id="new_job_level" class="form-control" /></td>
								<td class="text-right font-bold" >所属部门:</td>
								<td>
									<input type="text" id="job_de_name" readonly class="form-control" />
									<input type="hidden" id="job_de_id"/>
								</td>
							</tr>
							<tr>
								<td class="text-right font-bold" >说明:</td>
								<td colspan="3">
									<textarea id="new_job_remark" style="width:80%;height:100px;resize: none;" class="form-control"></textarea>
								</td>
								
							</tr>
					
                   	</table>
                   	<div class="row text-center">

            
                        
						<input type="button" value="新建岗位" id="bc" class="btn btn-primary btn-sm"/>
                       
                   	</div>
                </form>
            </div>
        </div>
       </div>
        <!--新增部门弹框-->
         <!--新增角色弹框-->
	<div class=" alerts" id="alert_addrole">
        <div class="alerts_content animated fadeInUp">
            <h3><span id="isrole">新增角色</span><a style="float: right;margin-right: 10px;font-size: 16px" id="del_this2">&times;</a></h3>
            <div  class="alerts_form">
                <form id="newrole">
                   	<table class="table table-bordered">
							<input type="hidden" value="0" id="add_up_role_id"/>
							<tr>
								<td class="text-right font-bold" >角色名称<span style="color: red">*</span>:</td>
								<td><input type="text" class="form-control"  id="add_up_role_name"/></td>
							</tr>
							<tr>
								<td class="text-right font-bold" >上级角色:</td>
								<td>
									<span id="add_up_role_pid_kg"></span>
									<input type="hidden" id="add_up_role_pid" value=""/>
									<a href='javascript:;' id="add_up_choose">选择</a>
								</td>
							</tr>
							<tr>
								<td class="text-right font-bold" >说明:</td>
								<td colspan="3">
									<textarea id="add_up_role_remark" style="width:80%;height:200px;resize: none;" class="form-control"></textarea>
								</td>
								
							</tr>
					
                   	</table>
                   	<div class="row text-center">

            
                        
						<input type="button" value="保存角色" id="bcrole" class="btn btn-sm btn-primary"/>
                       
                   	</div>
                </form>
            </div>
        </div>
      </div>
        <!--新增角色弹框-->
 		    <!--新增角色弹框-->
	<div class=" alerts" id="alert_addroleg">
        <div class="alerts_content animated fadeInUp">
            <h3><span id="isroleg">新增角色组</span><a style="float: right;margin-right: 10px;font-size: 16px" id="del_this3">&times;</a></h3>
            <div  class="alerts_form">
                <form id="newroleg">
                   	<table class="table table-bordered">
							<input type="hidden" value="0" id="add_up_roleg_id"/>
							<tr>
								<td class="text-right font-bold">角色组名称<span style="color: red">*</span>:</td>
								<td ><input type="text" id="add_up_roleg_name" class="form-control" /></td>
							</tr>
							<tr>
								<td class="text-right font-bold" >角色组合<span style="color: red">*</span>:</td>
								<td>
									<span id="add_up_roleg_pid_kg"></span>
									<input type="hidden" id="add_up_roleg_pid" value=""/>
									<a href='javascript:;' id="add_roleg_choose">选择</a>
								</td>
							</tr>
							<tr>
								<td class="text-right font-bold" >说明:</td>
								<td colspan="3">
									<textarea id="add_up_roleg_remark" style="width:80%;height:200px;resize: none;" class="form-control"></textarea>
								</td>
								
							</tr>
					
                   	</table>
                   	<div class="row text-center">

            
                        
						<input type="button" value="保存角色组" id="bcroleg" class="btn btn-primary btn-sm"/>
                       
                   	</div>
                </form>
            </div>
        </div>
      </div>

        <!--新增角色弹框-->
    <!-- 全局js -->
    <script src="__STATIC__/layout/js/jquery.min.js?v=2.1.4"></script>
    <script src="__STATIC__/layout/js/bootstrap.min.js?v=3.3.6"></script>
     <!-- Peity -->
    <script src="__STATIC__/layout/js/plugins/peity/jquery.peity.min.js"></script>

    <!-- jqGrid -->
    <script src="__STATIC__/layout/js/plugins/jqgrid/i18n/grid.locale-cn.js?0820"></script>
    <script src="__STATIC__/layout/js/plugins/jqgrid/jquery.jqGrid.min.js?0820"></script>

    <!-- 自定义js -->
    <script src="__STATIC__/layout/js/content.js?v=1.0.0"></script>
     <script src="__STATIC__/layout/js/plugins/sweetalert/sweetalert.min.js"></script>
     <!-- layerDate plugin javascript -->
    <script src="__STATIC__/layout/js/plugins/layer/laydate/laydate.js"></script>
    <!-- ztree -->
    <script type="text/javascript" src="__STATIC__/zTreeStyle/jquery.ztree.core.js"></script>
    <script type="text/javascript" src="__STATIC__/zTreeStyle/jquery.ztree.excheck.js"></script>
    <script src="__STATIC__/layout/js/plugins/layer/layer.min.js"></script>
    <script src="__STATIC__/layout/js/plugins/suggest/bootstrap-suggest.min.js"></script>

    <!--统计代码，可删除-->
  	<script type="text/javascript">
  	$('body').on('click','.duoxuan .close',function () {
        $(this).closest('.ren').remove()
    })
  	//网点弹出搜索
  	$('#select_net').on('click',function () {
                var index = layer.getFrameIndex(window.name)
                var netlist=backnet();
		        if(netlist.length==0){
		        	layer.open({
	                    type:2,
	                    area:['60%','60%'],
	                    maxmin:true,
	                    content:'{:url("selectnet")}'
	                })
		        }else{
		        	
		        	layer.open({
	                    type:2,
	                    area:['60%','60%'],
	                    maxmin:true,
	                    content:'{:url("selectnet")}?netids='+netlist
	                })
		        }
                
                return  false
        })
  	function backnet(){
  		var netlist=[];
                var i=0;
                $('#selected_net .ren').each(function () {
		            netlist[i]=$(this).attr('data-id');
		            i++;
		        })
		 return netlist.join(',');
  	}
  	$("#netlist").bsSuggest({
            url: "{:url('netjson')}",
            /*effectiveFields: ["userName", "shortAccount"],
             searchFields: [ "shortAccount"],*/
            effectiveFieldsAlias:{title: "名称"},
            ignorecase: true,
            showHeader: true,
            showBtn: false,     //不显示下拉按钮
            delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
            idField: "id",
            keyField: "title",
            clearable: true
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword, data) {
           //alert();
           $(this).val('')
	        var bool = false
	        $('#selected_net .ren').each(function (idx,o) {
	            if($(this).data('id') == keyword.id){
	                bool = true;
	            }
	        })
	        if(bool == false){
	            $('#selected_net').append('<span class="ren prolist" data-id="'+keyword.id+'">'+keyword.key+'<span class="close">×</span></span>');
	           	
	        }
        });
  	//系统弹出搜索
  	 $('#select_sys').on('click',function () {
                var index = layer.getFrameIndex(window.name)
                var syslist=backsys();
		        if(syslist.length==0){
		        	layer.open({
	                    type:2,
	                    area:['60%','60%'],
	                    maxmin:true,
	                    content:'{:url("selectsys")}'
	                })
		        }else{
		        	
		        	layer.open({
	                    type:2,
	                    area:['60%','60%'],
	                    maxmin:true,
	                    content:'{:url("selectsys")}?sysids='+syslist
	                })
		        }
                
                return  false
        })
  	function backsys(){
  		var syslist=[];
                var i=0;
                $('#selected_sys .ren').each(function () {
		            syslist[i]=$(this).attr('data-id');
		            i++;
		        })
		 return syslist.join(',');
  	}
  	$("#syslist").bsSuggest({
            url: "{:url('sysjson')}",
            /*effectiveFields: ["userName", "shortAccount"],
             searchFields: [ "shortAccount"],*/
            effectiveFieldsAlias:{title: "名称"},
            ignorecase: true,
            showHeader: true,
            showBtn: false,     //不显示下拉按钮
            delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
            idField: "id",
            keyField: "title",
            clearable: true
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword, data) {
           //alert();
           $(this).val('')
	        var bool = false
	        $('#selected_sys .ren').each(function (idx,o) {
	            if($(this).data('id') == keyword.id){
	                bool = true;
	            }
	        })
	        if(bool == false){
	            $('#selected_sys').append('<span class="ren prolist" data-id="'+keyword.id+'">'+keyword.key+'<span class="close">×</span></span>');
	           	
	        }
        });
  	function backjxs(){
  		var jxslist=[];
                var i=0;
                $('#selected_jxs .ren').each(function () {
		            jxslist[i]=$(this).attr('data-id');
		            i++;
		        })
		 return jxslist.join(',');
  	}
  	//用户经销商弹出搜索
  	 $('#select_jxs').on('click',function () {
                var index = layer.getFrameIndex(window.name)
                var jxslist=backjxs();
		        if(jxslist.length==0){
		        	layer.open({
	                    type:2,
	                    area:['60%','60%'],
	                    maxmin:true,
	                    content:'{:url("selectjxs")}'
	                })
		        }else{
		        	
		        	layer.open({
	                    type:2,
	                    area:['60%','60%'],
	                    maxmin:true,
	                    content:'{:url("selectjxs")}?jxsids='+jxslist
	                })
		        }
                
                return  false
        })
  	 $("#jxslist").bsSuggest({
            url: "{:url('jxsjson')}",
            /*effectiveFields: ["userName", "shortAccount"],
             searchFields: [ "shortAccount"],*/
            effectiveFieldsAlias:{title: "名称"},
            ignorecase: true,
            showHeader: true,
            showBtn: false,     //不显示下拉按钮
            delayUntilKeyup: true, //获取数据的方式为 firstByUrl 时，延迟到有输入/获取到焦点时才请求数据
            idField: "id",
            keyField: "title",
            clearable: true
        }).on('onDataRequestSuccess', function (e, result) {
            console.log('onDataRequestSuccess: ', result);
        }).on('onSetSelectValue', function (e, keyword, data) {
           //alert();
           $(this).val('')
	        var bool = false
	        $('#selected_jxs .ren').each(function (idx,o) {
	            if($(this).data('id') == keyword.id){
	                bool = true;
	            }
	        })
	        if(bool == false){
	            $('#selected_jxs').append('<span class="ren prolist" data-id="'+keyword.id+'">'+keyword.key+'<span class="close">×</span></span>');
	           	
	        }
        });
  	function powerlist(rid){
  		layer.open({
                type:2,
                area:['60%','60%'],
                maxmin:true,
                content:'{:url("Role/powerlist")}?rid='+rid
            })
  	}
  	//分配菜单
  	$("#update_power").click(function(){
  		if($("#role_id").val()==""||$("#role_id").val()==0){
  			swal({
				    title: "提示",
				    text: "请先选择一个角色",
				    type: "warning"
			});
  		}else{
  			layer.open({
                type:2,
                area:['60%','60%'],
                maxmin:true,
                content:'{:url("Role/powerlist")}?rid='+$("#role_id").val()
            })
  		}
  	})
  	function zcpwd(login_id){
  		//重置密码参数帐号
  		swal({
	                        title: "提示",
	                        text: "您是否确认要将用户的密码重置为111111",
	                        type: "warning",
	                        showCancelButton: true,
	                        confirmButtonColor: "#33FF33",
	                        confirmButtonText: "确认",
	                        cancelButtonText: "取消",
	                        closeOnConfirm: true
	                    },
	                    function (isConfirm) {
	                    	if (isConfirm) {
	                    		$.post("{:url('Employees/resetpwd')}",{id:login_id},function(re){
	                    		if(re==1){
	                    			alert("操作已成功")
	                    		}else{
	                    			alert("系统繁忙请稍后再试")
	                    		}
	                    	})
	                    	}
	                    	
	                    }
	                )
  	}
  	       //获取已经被选中的其他部门
    function get_choose_other_role(){
    	var other_dei=0;
    	var other_de_arr=new Array();
    	$("#add_up_roleg_pid_kg>span").each(function(){
    		other_de_arr[other_dei]=$(this).attr("rid");
    		other_dei++;
    	})
    	return other_de_arr.join(',');
    }
 //查询角色组包含角色
        function get_group_c_role(){
        	var str="";
        	if($("#roleg_id").val()!=""){
        		$.post("{:url('Employees/getgcr')}",{rgid:$("#roleg_id").val()},function(re){
        			$("#cont_role").html(re);
        		})
        	}else{
        		$("#cont_role").html(str);
        	}
        	
        }
  	$("#back").click(function(){
  		location.href="{:url('Employees/manage')}";
  	})
  	//保存角色组
  	var regex_roleg_name=/^[a-zA-Z0-9\u4e00-\u9fa5]{1,20}$/;
  	$("#bcroleg").click(function(){
  		var msg="";
  		var rids=get_choose_other_role();
  		//alert(rids);
  		if($("#add_up_roleg_name").val()==""){
  			msg="角色组名不能为空";
  		}else if(!regex_roleg_name.test($("#add_up_roleg_name").val())){
  			msg="角色组名为字母，数字,中文组成且长度不超过20";
  		}else if(rids==""){
  			msg="至少一个角色";
  		}
  		if(msg!=""){
  			swal({
                        title: "提示",
                        text: msg,
                        type: "warning"
                    });
  		}else{
  			
  				$.ajax({
                    type: "POST",
                    url: "{:url('Employees/role_group_edit')}",
                    async: false,
                    data: "id="+$("#add_up_roleg_id").val()+"&group_name="+$("#add_up_roleg_name").val()+"&remark="+$("#add_up_roleg_remark").val()+"&rids="+rids,
                    success: function(msg){
                    	//alert(msg);
                            if(msg==1){
                            	swal({
			                        title: "完成",
			                        text: "角色修改已完成",
			                        type: "success"
			                    },function(){
			                    	$("#alert_addroleg").hide();
			                    	get_group_c_role();
			                    });
                            }else{
                            	var wrong_new_job="";
                            	switch(msg){
                            		case 0:wrong_new_job="非法提交";break;
                            		case 5:wrong_new_job="至少分配一个角色";break;
                            		case 4:wrong_new_job="角色组名不能为空";break;
                            		case 3:wrong_new_job="角色组名已存在";break;
                            		default:wrong_new_job="系统繁忙，请稍后";break;
                            	}
									swal({
				                        title: "错误",
				                        text: wrong_new_job,
				                        type: "warning"
				                    });

                            }
                    }
                });

  		}
  	})
//新建角色弹框
  	$("#new_roleg").click(function(){
  		$("#add_up_roleg_id").val(0);
  		$("#add_up_roleg_name").val("");
  		$("#add_up_roleg_remark").val("");
  		$("#add_up_roleg_pid_kg").html("");
  		$("#add_up_roleg_pid").val("");
  		$("#isroleg").html("新增角色组");
  		$("#alert_addroleg").show();
  	})
//修改角色组
$("#up_roleg").click(function(){
	if($("#roleg_id").val()==""){
				swal({
                        title: "提示",
                        text: "请先选择一个角色组",
                        type: "warning"
                    });
	}else{
		$("#add_up_roleg_name").val("");
  		$("#add_up_roleg_remark").val("");
  		$("#add_up_roleg_pid_kg").html("");
  		$("#add_up_roleg_pid").val("");
		$("#add_up_roleg_id").val($("#roleg_id").val());
		$.post("{:url('Employees/getrolegroup_de')}",{rgid:$("#roleg_id").val()},function(re){
			var data=JSON.parse(re);
			if(data.length>0){
				$("#add_up_roleg_name").val(data[0]["group_name"]);
				$("#add_up_roleg_remark").val(data[0]["remark"]);
				for(var i=0;i<data.length;i++){
					var str="<span rid='"+data[i]["rid"]+"' style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>"+data[i]["role_name"]+"&nbsp;&nbsp;<span onclick='qxrg("+data[i]["rid"]+");' style='cursor:pointer;font-size:16px'>x</span></span>";
		    		$("#add_up_roleg_pid_kg").append(str);
				}
			}
		})
  		/*$("#add_up_roleg_name").val("");
  		$("#add_up_roleg_remark").val("");
  		$("#add_up_roleg_pid_kg").html("");
  		$("#add_up_roleg_pid").val("");*/
  		$("#isroleg").html("编辑角色组");
  		$("#alert_addroleg").show();
	}
  		
})

//关闭角色组
	$("#del_this3").click(function(){
  		$("#add_up_roleg_id").val(0);
  		$("#add_up_roleg_name").val("");
  		$("#add_up_roleg_remark").val("");
  		$("#add_up_roleg_pid_kg").html("");
  		$("#add_up_roleg_pid").val("");
  		$("#alert_addroleg").hide();
  	})
  	var regex_role_name=/^[a-zA-Z0-9\u4e00-\u9fa5]{1,20}$/;
  	$("#bcrole").click(function(){
  		var errormsg="";
  		//基础验证
  		if($("#add_up_role_name").val()==""){
  			errormsg="角色名不能为空";
  		}else if(!regex_role_name.test($("#add_up_role_name").val())){
  			errormsg="角色名为字母，数字，中文组成且长度不超过20";
  		}
  		if(errormsg==""){
  			if($("#add_up_role_id").val()==0){
  			//新增角色
  				 $.ajax({
                    type: "POST",
                    url: "{:url('Employees/new_role')}",
                    async: false,
                    data: "role_name="+$("#add_up_role_name").val()+"&parent_id="+$("#add_up_role_pid").val()+"&remark="+$("#add_up_role_remark").val(),
                    success: function(msg){
                    	//alert(msg);
                            if(msg==1){
                            	swal({
			                        title: "完成",
			                        text: "新的角色已添加",
			                        type: "success"
			                    },function(){
			                    	$("#alert_addrole").hide();
			                    });
                            }else{
                            	var wrong_new_job="";
                            	switch(msg){
                            		case 0:wrong_new_job="非法提交";break;
                            		case 2:wrong_new_job="角色名不能为空";break;
                            		case 4:wrong_new_job="角色名已存在";break;
                            		default:wrong_new_job="系统繁忙，请稍后";break;
                            	}
									swal({
				                        title: "错误",
				                        text: wrong_new_job,
				                        type: "warning"
				                    });

                            }
                    }
                });
  			}else{
  				//修改角色
  				$.ajax({
                    type: "POST",
                    url: "{:url('Employees/update_role')}",
                    async: false,
                    data: "role_name="+$("#add_up_role_name").val()+"&parent_id="+$("#add_up_role_pid").val()+"&remark="+$("#add_up_role_remark").val()+"&role_id="+$("#add_up_role_id").val(),
                    success: function(msg){
                    	//alert(msg);
                            if(msg==1){
                            	swal({
			                        title: "完成",
			                        text: "角色修改已完成",
			                        type: "success"
			                    },function(){
			                    	$("#alert_addrole").hide();
			                    });
                            }else{
                            	var wrong_new_job="";
                            	switch(msg){
                            		case 0:wrong_new_job="非法提交";break;
                            		case 2:wrong_new_job="角色名不能为空";break;
                            		case 4:wrong_new_job="角色名已存在";break;
                            		default:wrong_new_job="系统繁忙，请稍后";break;
                            	}
									swal({
				                        title: "错误",
				                        text: wrong_new_job,
				                        type: "warning"
				                    });

                            }
                    }
                });
  			}
  		}else{
  			swal({
                        title: "提示",
                        text: errormsg,
                        type: "warning"
                    });
  		}
  		
  	})
  	//新建角色弹框
  	$("#new_role").click(function(){
  		$("#add_up_role_id").val(0);
  		$("#add_up_role_name").val("");
  		$("#add_up_role_pid_kg").html("");
  		$("#add_up_role_pid").val("");
  		$("#add_up_role_remark").val("");
  		$("#isrole").html("新增角色");
  		$("#alert_addrole").show();
  	})
  	//修改角色弹框
  	$("#update_role").click(function(){
  		if($("#role_id").val()==""){
  			//未选择角色不能修改
        		swal({
                        title: "提示",
                        text: "角色选择完成后才能修改",
                        type: "warning"
                    });
  		}else{
  			$("#add_up_role_id").val($("#role_id").val());
  			$.post("{:url('Employees/checkrole_p')}",{roleid:$("#role_id").val()},function(re){
  				//alert(re);
  				var data=JSON.parse(re);
  				if(data.length>0){
  					$("#add_up_role_id").val(data[0]["id"]);
  					$("#add_up_role_name").val(data[0]["role_name"]);
  					if(data[0]["pname"]!=null){
  						$("#add_up_role_pid_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'><span class='departsdename'>"+data[0]["pname"]+"</span>&nbsp;&nbsp;<span onclick='qxadduprole();' style='cursor:pointer;font-size:16px'>x</span></span>");
  					}
  					
  					$("#add_up_role_pid").val(data[0]["pid"]);
  					$("#add_up_role_remark").val(data[0]["remark"]);
  						$("#isrole").html("编辑角色");
  					$("#alert_addrole").show();
  				}

  			})
  		}

  	});
  	$("#del_this2").click(function(){
  		$("#add_up_role_id").val(0);
  		$("#add_up_role_name").val("");
  		$("#add_up_role_pid_kg").html("");
  		$("#add_up_role_pid").val("");
  		$("#add_up_role_remark").val("");
  		
  		$("#alert_addrole").hide();
  	})
  	//新建岗位弹框
  	$("#new_job").click(function(){
  		if($("#de_id").val()==""){
        		//主部门未选弹框提示
        		swal({
                        title: "提示",
                        text: "请优先选择主部门",
                        type: "warning"
                    });
        	}else{
        		$(".alert_addjob input[type='text']").val("");
        		$(".alert_addjob input[type='hidden']").val("");
        		$("#new_pid_kg").html("");
        		$(".alert_addjob textarea").val("");
        		$("#job_de_id").val($("#de_id").val());
        		$("#job_de_name").val($("#depart_kg>span>.departsdename").html());
        		$(".alert_addjob").show();

        	}
  		
  	})

  	$("#del_this").click(function(){
  		$(".alert_addjob").hide();
  	})
  	//新建岗位验证
  	//岗位名和对外称谓验证
  	//中文，字母，数字1-20位
  	var regex_job_name=/^[a-zA-Z0-9\u4e00-\u9fa5]{1,20}$/;
  	var regex_job_no=/^[a-zA-Z0-9]{1,10}$/;
  	 $("#new_job_level").keyup(function(){

            if(isNaN(parseInt($(this).val()))){
                $(this).val("");
            }else{
                $(this).val(parseInt($(this).val()));
            }
            
        })
  	$("#bc").click(function(){
  		if($("#new_job_name").val()==""){
  			swal({
                        title: "错误",
                        text: "岗位名称不能为空",
                        type: "warning"
                    });return;
  		} 
  		if(!regex_job_name.test($("#new_job_name").val())){
  			swal({
                        title: "错误",
                        text: "岗位名称为字母，数字和中文组成且长度不超过20",
                        type: "warning"
                    });return;
  		}
  		if($("#new_job_title").val()==""){
  			swal({
                        title: "错误",
                        text: "对外称谓不能为空",
                        type: "warning"
                    });return;
  		} 
  		if(!regex_job_name.test($("#new_job_title").val())){
  			swal({
                        title: "错误",
                        text: "对外称谓为字母，数字和中文组成且长度不超过20",
                        type: "warning"
                    });return;
  		}
  		//new_job_no
  		if($("#new_job_no").val()==""){
  			swal({
                        title: "错误",
                        text: "岗位编码不能为空",
                        type: "warning"
                    });return;
  		} 
  		if(!regex_job_no.test($("#new_job_no").val())){
  			swal({
                        title: "错误",
                        text: "岗位编码为字母，数字组成且长度不超过10",
                        type: "warning"
                    });return;
  		}
  		if($("#new_job_level").val()==""){
  			swal({
                        title: "错误",
                        text: "岗位等级不能为空",
                        type: "warning"
                    });return;
  		}
  		if($("#job_de_id").val()==""){
  			swal({
                        title: "错误",
                        text: "所属部门不能为空",
                        type: "warning"
                    });return;
  		}
  		 $.ajax({
                    type: "POST",
                    url: "{:url('Employees/new_job')}",
                    async: false,
                    data: "job_name="+$("#new_job_name").val()+"&job_title="+$("#new_job_title").val()+"&parent_id="+$("#new_pid").val()+"&job_no="+$("#new_job_no").val()+"&job_level="+$("#new_job_level").val()+"&department_id="+$("#job_de_id").val()+"&remark="+$("#new_job_remark").val(),
                    success: function(msg){
                    	//alert(msg);
                            if(msg==1){
                            	swal({
			                        title: "完成",
			                        text: "新的岗位已添加",
			                        type: "success"
			                    },function(){
			                    	$(".alert_addjob").hide();
			                    });
                            }else{
                            	var wrong_new_job="";
                            	switch(msg){
                            		case 0:wrong_new_job="非法提交";break;
                            		case 2:wrong_new_job="岗位编号不能为空";break;
                            		case 3:wrong_new_job="岗位名称不能为空";break;
                            		case 4:wrong_new_job="对外称谓不能为空";break;
                            		case 5:wrong_new_job="岗位等级不能为空";break;
                            		case 6:wrong_new_job="所属部门不能为空";break;
                            		case 7:wrong_new_job="系统繁忙，请稍后";break;
                            		case 8:wrong_new_job="岗位名或编号已存在";break;
                            		default:wrong_new_job="系统繁忙，请稍后";break;
                            	}
									swal({
				                        title: "错误",
				                        text: wrong_new_job,
				                        type: "warning"
				                    });

                            }
                    }
                });
  	})
	var regex_em_name=/^[a-zA-Z0-9\.\u4e00-\u9fa5]{1,20}$/;
	var regex_mobile=/^1[3458]\d{9}$/; 
	//微信号6-20位字母，数字，下划线或者减号以字母开头
	var regex_we=/^[a-zA-Z][a-zA-Z0-9_-]{5,19}$/;
	var regex_email=/^[a-zA-Z0-9_-]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/;
	var regex_idc=/(^\d{15}$)|(^\d{18}$)|(^\d{17}[xX]$)/;
	var regex_login_name=/^\w{4,16}$/;
	var regex_login_pwd=/^[a-zA-Z0-9]{4,8}$/;
  	//点击提交
  	$("#submits").click(function(){

  		
  			//新建
  			var eromsg="";
            //仅创建员工验证
            if($("#em_num").val()==""){
                eromsg="员工编号不能为空";
            }else if(!regex_job_no.test($("#em_num").val())){
				eromsg="员工编号为字母，数字组成且长度不超过10";
            }else if($("#em_name").val()==""){
                eromsg="员工姓名不能为空";
            }else if(!regex_em_name.test($("#em_num").val())){
                eromsg="员工姓名为字母，数字组成且长度不超过20,如有分割请使用.";
            }else if($("#mobile").val()==""){
                eromsg="手机号不能为空";
            }else if(!regex_mobile.test($("#mobile").val())){
				eromsg="手机号格式不正确";
            }else if($("#wechart").val()!=""){
                if(!regex_we.test($("#wechart").val())){
                    eromsg="微信号格式6-20位字母，数字，下划线或者减号以字母开头";
                }
            }else if($("#email").val()!=""){
                if(!regex_email.test($("#email").val())){
                    eromsg="邮箱格式不正确";
            	}
            }else if($("#idcard").val()!=""){
                if(!regex_idc.test($("#idcard").val())){
                    eromsg="身份证号格式不正确";
                }
            }else if($("#de_id").val()==""){
            	 eromsg="必须选择主部门";
            }else if($("#job_id").val()==""){
            	eromsg="必须选择岗位";
            }
        if(eromsg==""){
            	    //判断修改或新建
	  		if($("#employee_id").val()=="0"){

	  			//判断是否有帐号信息,只看帐号密码
	  			if($("#login_name").val()==""){
	  				swal({
	                        title: "提示",
	                        text: "您尚未填写用户帐号密码，系统将不会为此员工开设帐号",
	                        type: "warning",
	                        showCancelButton: true,
	                        confirmButtonColor: "#33FF33",
	                        confirmButtonText: "确认",
	                        cancelButtonText: "取消完善帐号信息",
	                        closeOnConfirm: true
	                    },
	                    function (isConfirm) {
	                        if (isConfirm) {
	                        	//创建提交
	                        	var odepart=get_choose_other_depart();
	                        	$(".alert_addNewZone_tree").show();
	            				$("#txtree").html("");
	            				$("#fenqu_fzr").hide();
	                			$(".wait").show();
	                			$.post("{:url('Employees/new_employee')}",{
	                				em_no:$("#em_num").val(),
	                				em_name:$("#em_name").val(),
	                				state:$("input[name='state']:checked").val(),
	                				mobile:$("#mobile").val(),
	                				wechart:$("#wechart").val(),
	                				email:$("#email").val(),
	                				idcard:$("#idcard").val(),
	                				entry:$("#entry").val(),
	                				gender:$("input[name='gender']:checked").val(),
	                				de_id:$("#de_id").val(),
	                				is_main:$("#is_main").val(),
	                				job_id:$("#job_id").val(),
	                				otherdepart:odepart
	                			},function(re){
	                				//alert(re);
									$(".alert_addNewZone_tree").hide();
	                				$("#fenqu_fzr").show();
	                				$(".wait").hide();
	                				if(re==1){
	                					alert("操作已完成")
					                    	location.href='{:url("Employees/manage")}';
					                   
	                				}else{
	                					var zcwrong="";
	                					if(re==2){
	                						zcwrong="员工编号已存在";
	                					}else{
	                						zcwrong="系统繁忙，请稍后";
	                					}
	                					swal({
										    title: "错误",
										    text: zcwrong,
										    type: "warning"
										});
	                				}
	                			})
	                        } 
	                    });
	  			}else{
	  				//创建员工和帐号有帐号
	  				var login_user_msg="";
	  				if(!regex_login_name.test($("#login_name").val()) ){
	  					login_user_msg="帐号格式不正确";
	  				}
	  				if(!regex_login_pwd.test($("#login_pwd").val())){
	  					login_user_msg="密码格式不正确";
	  				}
	  				if($("#role_id").val()==""){
	  					login_user_msg="角色不能为空";
	  				}
	  				if(login_user_msg!=""){
	  					swal({
							title: "错误",
							text: login_user_msg,
							type: "warning"
						});
	  				}else{
	  					         	//创建提交
	                        	var odepart=get_choose_other_depart();
	                        	var jxslist=backjxs();
	                        	var syslist=backsys();
	                        	var netlist=backnet();
	                        	$(".alert_addNewZone_tree").show();
	            				$("#txtree").html("");
	            				$("#fenqu_fzr").hide();
	                			$(".wait").show();
	                			$.post("{:url('Employees/new_employee_user')}",{
	                				em_no:$("#em_num").val(),
	                				em_name:$("#em_name").val(),
	                				state:$("input[name='state']:checked").val(),
	                				mobile:$("#mobile").val(),
	                				wechart:$("#wechart").val(),
	                				email:$("#email").val(),
	                				idcard:$("#idcard").val(),
	                				entry:$("#entry").val(),
	                				gender:$("input[name='gender']:checked").val(),
	                				de_id:$("#de_id").val(),
	                				is_main:$("#is_main").val(),
	                				job_id:$("#job_id").val(),
	                				otherdepart:odepart,
	                				login_name:$("#login_name").val(),
	                				login_pwd:$("#login_pwd").val(),
	                				user_type:$("input[name='user_type']:checked").val(),
	                				user_state:$("input[name='user_state']:checked").val(),
	                				user_is_SFA:$("input[name='user_is_SFA']:checked").val(),
	                				user_power:$("input[name='user_power']:checked").val(),
	                				role_id:$("#role_id").val(),
	                				roleg_id:$("#roleg_id").val(),
	                				jxs_ids:jxslist,
	                				sys_ids:syslist,
	                				net_ids:netlist
	                			},function(re){
	                				//alert(re);
									$(".alert_addNewZone_tree").hide();
	                				$("#fenqu_fzr").show();
	                				$(".wait").hide();
	                				if(re==1){
	                					alert("操作已完成")
					                    	location.href='{:url("Employees/manage")}';
					                   
	                				}else{
	                					//alert(re);
	                					var zcwrong="";
	                					
	                					if(re==9){
	                						zcwrong="帐号已存在";
	                					}else if(re==2){
	                						zcwrong="员工编号已存在";
	                					}else{
	                						zcwrong="系统繁忙，请稍后";
	                					}
	                					swal({
										    title: "错误",
										    text: zcwrong,
										    type: "warning"
										});
	                				}
	                			})

	  				}
	  				
	  			}

	  		}else{
	  			//修改
	  			if($("#login_name").val()==""){
	  				//修改无帐号
	  				swal({
	                        title: "提示",
	                        text: "您尚未填写用户帐号密码，系统将不会为此员工开设帐号",
	                        type: "warning",
	                        showCancelButton: true,
	                        confirmButtonColor: "#33FF33",
	                        confirmButtonText: "确认",
	                        cancelButtonText: "取消完善帐号信息",
	                        closeOnConfirm: true
	                    },
	                    function (isConfirm) {
	                        if (isConfirm) {
	                        	//创建提交
	                        	var odepart=get_choose_other_depart();
	                        	$(".alert_addNewZone_tree").show();
	            				$("#txtree").html("");
	            				$("#fenqu_fzr").hide();
	                			$(".wait").show();
	                			$.post("{:url('Employees/update_employee')}",{
	                				emid:$("#employee_id").val(),
	                				em_no:$("#em_num").val(),
	                				em_name:$("#em_name").val(),
	                				state:$("input[name='state']:checked").val(),
	                				mobile:$("#mobile").val(),
	                				wechart:$("#wechart").val(),
	                				email:$("#email").val(),
	                				idcard:$("#idcard").val(),
	                				entry:$("#entry").val(),
	                				gender:$("input[name='gender']:checked").val(),
	                				de_id:$("#de_id").val(),
	                				is_main:$("#is_main").val(),
	                				job_id:$("#job_id").val(),
	                				otherdepart:odepart
	                			},function(re){
	                				
									$(".alert_addNewZone_tree").hide();
	                				$("#fenqu_fzr").show();
	                				$(".wait").hide();
	                				if(re==1){
	                					alert("操作已完成")
					                    	location.href='{:url("Employees/manage")}';
					                    
	                				}else{
	                					
	                					swal({
										    title: "错误",
										    text: "系统繁忙请稍后再试",
										    type: "warning"
										});
	                				}
	                			})
	                        } 
	                    });
	  			}else{
	  				//修改有帐号
	  				//   	//创建提交
	  				var login_user_msg="";
	  				if($("#role_id").val()==""){
	  					login_user_msg="角色不能为空";
	  				}
	  				if(login_user_msg!=""){
	  					swal({
							title: "错误",
							text: login_user_msg,
							type: "warning"
						});
	  				}else{
	  					var odepart=get_choose_other_depart();
	  					var jxslist=backjxs();
	  					var syslist=backsys();
	  					var netlist=backnet();
	                        	$(".alert_addNewZone_tree").show();
	            				$("#txtree").html("");
	            				$("#fenqu_fzr").hide();
	                			$(".wait").show();
	                			$.post("{:url('Employees/update_employee_user')}",{
	                				emid:$("#employee_id").val(),
	                				em_no:$("#em_num").val(),
	                				em_name:$("#em_name").val(),
	                				state:$("input[name='state']:checked").val(),
	                				mobile:$("#mobile").val(),
	                				wechart:$("#wechart").val(),
	                				email:$("#email").val(),
	                				idcard:$("#idcard").val(),
	                				entry:$("#entry").val(),
	                				gender:$("input[name='gender']:checked").val(),
	                				de_id:$("#de_id").val(),
	                				is_main:$("#is_main").val(),
	                				job_id:$("#job_id").val(),
	                				otherdepart:odepart,
	                				login_id:$("#login_id").val(),
	                				login_name:$("#login_name").val(),
	                				login_pwd:$("#login_pwd").val(),
	                				user_type:$("input[name='user_type']:checked").val(),
	                				user_state:$("input[name='user_state']:checked").val(),
	                				user_is_SFA:$("input[name='user_is_SFA']:checked").val(),
	                				user_power:$("input[name='user_power']:checked").val(),
	                				role_id:$("#role_id").val(),
	                				roleg_id:$("#roleg_id").val(),
	                				jxs_ids:jxslist,
	                				sys_ids:syslist,
	                				net_ids:netlist
	                			},function(re){
	                				//alert(re);
									$(".alert_addNewZone_tree").hide();
	                				$("#fenqu_fzr").show();
	                				$(".wait").hide();
	                				if(re==1){
	                					alert("操作已完成")
					                    	location.href='{:url("Employees/manage")}';
	                				}else{
	                					
	                					swal({
										    title: "错误",
										    text: "系统繁忙请稍后再试",
										    type: "warning"
										});
	                				}
	                			})
	  				
	  				}
	                        	
	  			}
	  		}
        }else{
        	swal({
				    title: "错误",
				    text: eromsg,
				    type: "warning"
				});
        }

  	})
  	/*---------树状图处理-----------*/
  	function qxroleg(){
        	$("#roleg_kg").html("");
  			$("#roleg_id").val("");
  			 get_group_c_role();
    }
  	//上级角色删除
  	function qxadduprole(){
  		$("#add_up_role_pid_kg").html("");
  		$("#add_up_role_pid").val("");
  	}
  	//部门删除
  	 function qxde(){
        	$("#depart_kg").html("");
            $("#de_id").val("");
    }
    //角色删除
    function qxrole(){
    		$("#role_kg").html("");
            $("#role_id").val("");
            $("#prole_kg").html("");
            $("#prole_id").val("");
    }
    //角色组删除
     function qxrg(rid){
    	  $("#add_up_roleg_pid_kg span[rid='"+rid+"']").remove();
    }
    //其他部门删除
    function qxode(did){
    	 $("#odepart_kg span[did='"+did+"']").remove();
    }
    //上级岗位伤处
    function qxpjob(){
    	$("#new_pid_kg").html("");
        $("#new_pid").val("");
    }
    //删除岗位
    function qxjob(){
    		$("#job_kg").html("");
            $("#job_id").val("");
    }
    //获取已经被选中的其他部门
    function get_choose_other_depart(){
    	var other_dei=0;
    	var other_de_arr=new Array();
    	$("#odepart_kg>span").each(function(){
    		other_de_arr[other_dei]=$(this).attr("did");
    		other_dei++;
    	})
    	return other_de_arr.join(',');
    }
  	$(function(){
  		 function disabledNode(e) {
            var zTree = $.fn.zTree.getZTreeObj("tree_em"),
            disabled = e.data.disabled,
            nodes = zTree.getSelectedNodes();
            if (nodes.length == 0) {
                alert("请先选择一个节点");
            }

            for (var i=0, l=nodes.length; i<l; i++) {
                zTree.setChkDisabled(nodes[i], disabled);
            }
        }
        //选择上级角色
        var setting_rolep={
            check: {
                enable: true,
                chkStyle: "radio",
                radioType: "all"
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback:{
                onCheck: rolepOnCheck
            }
        };
        //上级角色点击
         function rolepOnCheck(event, treeId, treeNode){
        	
        	if(treeNode.checked==true){
        		
  				$("#add_up_role_pid_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'><span class='departsdename'>"+treeNode.name+"</span>&nbsp;&nbsp;<span onclick='qxadduprole();' style='cursor:pointer;font-size:16px'>x</span></span>");
  					
  					
  				$("#add_up_role_pid").val(treeNode.id);
            }else{
               $("#add_up_role_pid_kg").html("");
  				$("#add_up_role_pid").val("");
            }
        }
        //打开树
          $("#add_up_choose").click(function(){
        	 $(".alert_addNewZone_tree").show();
	            $("#txtree").html("角色列表");
	            $("#fenqu_fzr").hide();
	                $(".wait").show();
	                	
	           $.post("{:url('Employees/get_prole_tree')}",{roleid:$("#add_up_role_id").val(),proleid:$("#add_up_role_pid").val()},function(re){
	           		var data_role=new Array();
	           		if(re!=""){
						data_role=JSON.parse(re);
	           		}
	                
	                
	                $("#fenqu_fzr").show();
	                $(".wait").hide();
	                $.fn.zTree.init($("#tree_em"), setting_rolep, data_role);
	                $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
	                $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
	           })
        })
          //选择角色组
          var setting_roleg={
            check: {
                enable: true,
                chkStyle: "radio",
                radioType: "all"
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback:{
                onCheck: rolegOnCheck
            }
        };

         get_group_c_role();
       
        //点击
        function rolegOnCheck(event, treeId, treeNode){
        	//roleg_kg  roleg_id
        	if(treeNode.checked==true){
        		
  				$("#roleg_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'><span class='departsdename'>"+treeNode.name+"</span>&nbsp;&nbsp;<span onclick='qxroleg();' style='cursor:pointer;font-size:16px'>x</span></span>");
  					
  					
  				$("#roleg_id").val(treeNode.id);
            }else{
               $("#roleg_kg").html("");
  				$("#roleg_id").val("");
            }
            get_group_c_role();
        	
        }//up_roleg
         $("#choose_roleg").click(function(){
        	 $(".alert_addNewZone_tree").show();
	            $("#txtree").html("角色组列表");
	            $("#fenqu_fzr").hide();
	                $(".wait").show();

	           $.post("{:url('Employees/get_roleg_tree')}",{roleid:0},function(re){
	           		var data_role=new Array();
	           		if(re!=""){
						data_role=JSON.parse(re);
	           		}
	                
	                
	                $("#fenqu_fzr").show();
	                $(".wait").hide();
	                $.fn.zTree.init($("#tree_em"), setting_roleg, data_role);
	                $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
	                $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
	           })
        })
        //选择角色
         var setting_role={
            check: {
                enable: true,
                chkStyle: "radio",
                radioType: "all"
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback:{
                onCheck: roleOnCheck
            }
        };

        function ckrole(){
        	if($("#role_id").val()!=""){
        		$.post("{:url('Employees/getrole_de')}",{roleid:$("#role_id").val()},function(re){
                	//alert(re);
                	var data=JSON.parse(re);
                	var parnode=data["role"];
                	if(parnode.length>0){
                		$("#prole_id").val(parnode[0]["id"]);
                		$("#prole_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>"+parnode[0]["role_name"]+"&nbsp;&nbsp;</span>");
                	}else{
                		 $("#prole_kg").html("");
                		$("#prole_id").val("");
                	}
                	var otherusers=data["user"];
                	if(otherusers.length>0){
                		var str="";
                		for(var i=0;i<otherusers.length;i++){
                			str+=otherusers[i]["em_name"];
                			if(i<otherusers.length-1){
                				str+=",";
                			}
                		}
                		$("#role_other_people").html(str);
                	}
                	var otherpuser=data["puser"];
                	var puserarr=[];
                	for(var i=0;i<otherpuser.length;i++){
                		puserarr[i]=otherpuser[i]["em_name"];
                	}
                	var puserstr=puserarr.join(',');
                	$("#p_role_people").html(puserstr);
                })
        	}
        }
        ckrole();
 //角色点击
        function roleOnCheck(event, treeId, treeNode){
        	$("#role_other_people").html("");
        	if(treeNode.checked==true){
        		$("#role_id").val(treeNode.id);
                $("#role_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>"+treeNode.name+"&nbsp;&nbsp;<span onclick='qxrole();' style='cursor:pointer;font-size:16px;'>x</span></span>");
                
                $.post("{:url('Employees/getrole_de')}",{roleid:treeNode.id},function(re){
                	//alert(re);
                	var data=JSON.parse(re);
                	var parnode=data["role"];
                	if(parnode.length>0){
                		$("#prole_id").val(parnode[0]["id"]);
                		$("#prole_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>"+parnode[0]["role_name"]+"&nbsp;&nbsp;</span>");
                	}else{
                		 $("#prole_kg").html("");
                		$("#prole_id").val("");
                	}
                	var otherusers=data["user"];
                	if(otherusers.length>0){
                		var str="";
                		for(var i=0;i<otherusers.length;i++){
                			str+=otherusers[i]["em_name"];
                			if(i<otherusers.length-1){
                				str+=",";
                			}
                		}
                		$("#role_other_people").html(str);
                	}
                		var otherpuser=data["puser"];
                	var puserarr=[];
                	for(var i=0;i<otherpuser.length;i++){
                		puserarr[i]=otherpuser[i]["em_name"];
                	}
                	var puserstr=puserarr.join(',');
                	$("#p_role_people").html(puserstr);
                })
                	
            }else{
               	$("#role_kg").html("");
                $("#role_id").val("");
                $("#prole_kg").html("");
                $("#prole_id").val("");
            }
        }

        $("#choose_role").click(function(){
        	 $(".alert_addNewZone_tree").show();
	            $("#txtree").html("角色列表");
	            $("#fenqu_fzr").hide();
	                $(".wait").show();

	           $.post("{:url('Employees/get_role_tree')}",{roleid:0},function(re){
	           		var data_role=new Array();
	           		if(re!=""){
						data_role=JSON.parse(re);
	           		}
	                
	                
	                $("#fenqu_fzr").show();
	                $(".wait").hide();
	                $.fn.zTree.init($("#tree_em"), setting_role, data_role);
	                $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
	                $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
	           })
        })
        //选择岗位
        var setting_job={
            check: {
                enable: true,
                chkStyle: "radio",
                radioType: "all"
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback:{
                onCheck: jobOnCheck
            }
        };
        //选择岗位
        function jobOnCheck(event, treeId, treeNode){
        	if(treeNode.checked==true){
        		$("#job_id").val(treeNode.id);
                $("#job_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>"+treeNode.name+"&nbsp;&nbsp;<span onclick='qxjob();' style='cursor:pointer;font-size:16px'>x</span></span>");
            }else{
               	$("#job_kg").html("");
                $("#job_id").val("");
            }
        }

        //获取岗位列表本部门
        $("#choose_job_this").click(function(){
        	if($("#de_id").val()==""){
        		//主部门未选弹框提示
        		swal({
                        title: "提示",
                        text: "请优先选择主部门",
                        type: "warning"
                    });
        	}else{
        		 $(".alert_addNewZone_tree").show();
	            $("#txtree").html("岗位列表");
	            $("#fenqu_fzr").hide();
	                $(".wait").show();

	           $.post("{:url('Employees/get_no_tree')}",{deid:$("#de_id").val()},function(re){
	           		var data_job=new Array();
	           		if(re!=""){
						data_job=JSON.parse(re);
	           		}
	                
	                
	                $("#fenqu_fzr").show();
	                $(".wait").hide();
	                $.fn.zTree.init($("#tree_em"), setting_job, data_job);
	                $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
	                $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
	           })
        	}
           
       })
        //获取岗位列表全部部门
        $("#choose_job_all").click(function(){
        	
        		 $(".alert_addNewZone_tree").show();
	            $("#txtree").html("岗位列表");
	            $("#fenqu_fzr").hide();
	                $(".wait").show();

	           $.post("{:url('Employees/get_no_tree')}",function(re){
	           		var data_job=new Array();
	           		if(re!=""){
						data_job=JSON.parse(re);
	           		}
	                
	                
	                $("#fenqu_fzr").show();
	                $(".wait").hide();
	                $.fn.zTree.init($("#tree_em"), setting_job, data_job);
	                $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
	                $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
	           })
        	
           
       })
        //选择上级岗位
        //设定
        var setting_pjob={
            check: {
                enable: true,
                chkStyle: "radio",
                radioType: "all"
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback:{
                onCheck: pjobOnCheck
            }
        };
        //选择上级岗位
        function pjobOnCheck (event, treeId, treeNode){
        	if(treeNode.checked==true){
               
                $("#new_pid").val(treeNode.id);
                $("#new_pid_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>"+treeNode.name+"&nbsp;&nbsp;<span onclick='qxpjob();' style='cursor:pointer;font-size:16px'>x</span></span>");
            }else{
               	$("#new_pid_kg").html("");
                $("#new_pid").val("");
            }
        }
        //获取岗位列表
        $(".new_job_partent_id").click(function(){
            $(".alert_addNewZone_tree").show();
            $("#txtree").html("岗位列表");
            $("#fenqu_fzr").hide();
                $(".wait").show();

           $.post("{:url('Employees/getjobs')}",function(re){
           		var data_job=new Array();
           		if(re!=""){
					data_job=JSON.parse(re);
           		}
                
                
                $("#fenqu_fzr").show();
                $(".wait").hide();
                $.fn.zTree.init($("#tree_em"), setting_pjob, data_job);
                $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
                $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
           })
       })

  		//选择部门弹框
  			//设定
  		    var setting_de = {
            check: {
                enable: true,
                chkStyle: "radio",
                radioType: "all"
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback:{
                onCheck: deOnCheck
            }
        };
        //部门树选择
        function deOnCheck(event, treeId, treeNode) {
            if(treeNode.checked==true){
               
                $("#de_id").val(treeNode.id);
                $("#depart_kg").html("<span style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'><span class='departsdename'>"+treeNode.name+"</span>&nbsp;&nbsp;<span onclick='qxde();' style='cursor:pointer;font-size:16px;'>x</span></span>");
            }else{
               	$("#depart_kg").html("");
                $("#de_id").val("");
            }
        }
       
        //获取主部门信息
         $("#choose_depart").click(function(){
            $(".alert_addNewZone_tree").show();
            $("#txtree").html("部门列表");
            $("#fenqu_fzr").hide();
                $(".wait").show();

           $.post("{:url('Departments/getbm')}",function(re){
                var data_de=JSON.parse(re);
                
                $("#fenqu_fzr").show();
                $(".wait").hide();
                $.fn.zTree.init($("#tree_em"), setting_de, data_de);
                $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
                $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
           })
       })

         //choose_other_depart所属其他部门
         //设定
  		    var setting_ode = {
            check: {
                enable: true,
                chkboxType: { "Y": "", "N": "" }
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback:{
                onCheck: odeOnCheck
            }
        };
         //部门树选择
        function odeOnCheck(event, treeId, treeNode) {
        	if(treeNode.checked==true){
           	//odepart_kg
               	var flag=0;
               	
		    	$("#odepart_kg span").each(function(){
		    		if(parseInt($(this).attr("did"))==parseInt(treeNode.id)){
		    			flag=1;
		    		}	
		    		
		    	})
		    	if(flag==0){
		    		var str="<span did='"+treeNode.id+"' style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>"+treeNode.name+"&nbsp;&nbsp;<span onclick='qxode("+treeNode.id+");' style='cursor:pointer;font-size:16px;'>x</span></span>";
		    		$("#odepart_kg").append(str);
		    	}
                
            }else{
               $("#odepart_kg span[did='"+treeNode.id+"']").remove();
            }
        }




        $("#choose_other_depart").click(function(){
        	if($("#de_id").val()==""){
        		//主部门未选弹框提示
        		swal({
                        title: "提示",
                        text: "请优先选择主部门",
                        type: "warning"
                    });
        	}else{
        		$(".alert_addNewZone_tree").show();
	            $("#txtree").html("部门列表");
	            $("#fenqu_fzr").hide();
	            $(".wait").show();
	            var odeids=get_choose_other_depart();
	            
	           $.post("{:url('Departments/getobm')}",{deid:$("#de_id").val(),odeids:odeids},function(re){
	           	//alert(re);
	           	
	                var data_ode=JSON.parse(re);
	                
	                $("#fenqu_fzr").show();
	                $(".wait").hide();
	                $.fn.zTree.init($("#tree_em"), setting_ode, data_ode);
	                $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
	                $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
	           })
        	}
            
       })
        //角色组树
         //设定
  		    var setting_rg = {
            check: {
                enable: true,
                chkboxType: { "Y": "", "N": "" }
            },
            data: {
                simpleData: {
                    enable: true
                }
            },
            callback:{
                onCheck: rgOnCheck
            }
        };
          //角色组树选择
        function rgOnCheck(event, treeId, treeNode) {
        	if(treeNode.checked==true){
           			//$("#add_up_roleg_pid_kg").html("");
  					//$("#add_up_roleg_pid").val("");
  				var flag=0;
               	
		    	$("#add_up_roleg_pid_kg span").each(function(){
		    		if(parseInt($(this).attr("rid"))==parseInt(treeNode.id)){
		    			flag=1;
		    		}	
		    		
		    	})
		    	if(flag==0){
		    		var str="<span rid='"+treeNode.id+"' style='background:#d0e0e0;border:1px solid #ccc;border-radius:5px;padding:2px 3px;margin-right:5px'>"+treeNode.name+"&nbsp;&nbsp;<span onclick='qxrg("+treeNode.id+");' style='cursor:pointer;font-size:16px;'>x</span></span>";
		    		$("#add_up_roleg_pid_kg").append(str);
		    	}
                
                
            }else{
                $("#add_up_roleg_pid_kg span[rid='"+treeNode.id+"']").remove();
            }
        }
 
        $("#add_roleg_choose").click(function(){
        	$(".alert_addNewZone_tree").show();
	            $("#txtree").html("角色列表");
	            $("#fenqu_fzr").hide();
	            $(".wait").show();
	            var rids=get_choose_other_role();
	            
	           $.post("{:url('Employees/getallrole')}",{rids:rids},function(re){
	           	//alert(re);
	           	
	                var data_ode=JSON.parse(re);
	                
	                $("#fenqu_fzr").show();
	                $(".wait").hide();
	                $.fn.zTree.init($("#tree_em"), setting_rg, data_ode);
	                $("#disabledTrue").bind("click", {disabled: true}, disabledNode);
	                $("#disabledFalse").bind("click", {disabled: false}, disabledNode);
	           })
        })

        
         //关闭树
        
    	$("#del_this1").click(function(){
             
    		$(".alert_addNewZone_tree").hide();
    	})
        $("#qd").click(function(){
            
            $(".alert_addNewZone_tree").hide();
        })

  	})

/*---------树状图处理-----------*/

   	</script>
</body>

</html>
